package com.zsrt.day20170411.pm;

import java.util.Scanner;

import org.junit.Test;

/**
*@author jzh
*@创建时间 2017年4月11日下午5:58:18
*类说明：
*/
public class Student1Test {
	@Test
	public void student1Test(){
		//定义
		Student1[] student1s=new Student1[]{
				new Student1("贾梦菊",23,66,"女"),new Student1("张嘉源",21,76,"男"),new Student1("罗智壕",21,56,"男"),
				new Student1("何小强",28,86,"男")
		};
		
		Student1[] student1s2=new Student1[student1s.length+1];
		Student1 s1=new Student1();
		
		//从键盘输入学生信息
		Scanner in=new Scanner(System.in);
		System.out.println("输入名字：");
		String name = in.next();
		if(name.length()>=2&&name.length()<=4){
			System.out.println("输入正确，名字已赋值");
			s1.setName(name);
		}else{
			System.out.println("名字输入错误");
			return;
		}
		
		System.out.println("输入年龄：");
		int age = in.nextInt();
		if(age>=0&&age<=120){
			System.out.println("输入正确，年龄已赋值");
			s1.setAge(age);
		}else{
			System.out.println("年龄输入错误");
			return;
		}
		
		System.out.println("输入分数,double类型的：");
		double score = in.nextDouble();
		if(score>=0.0&&score<=100.0){
			System.out.println("输入正确，分数已赋值");
			s1.setScore(score);
		}else{
			System.out.println("分数输入错误");
			return;
		}
		
		System.out.println("输入性别：");
		String sex=in.next();
		in.close();
		if(sex.equals("男")||sex.equals("女")){
			System.out.println("输入正确，性别已赋值");
			s1.setSex(sex);
		}else{
			System.out.println("性别输入错误");
			return;
		}
		//把录入的信息保存到数组
		student1s2[4]=s1;
		//显示数组
		System.out.println("显示每个人的信息：");
		for(int i=0;i<student1s.length;i++){
			student1s2[i]=student1s[i];
		}
		for(int i=0;i<student1s2.length;i++){
			System.out.println(student1s2[i]);
		}
		
		//查找成绩在70<=score<=80的人
		for(int i=0;i<student1s2.length;i++){
			double d=student1s2[i].getScore();
			if(d>=70&&d<=80){
				System.out.println("成绩在70<=score<=80的人是："+student1s2[i].getName());
			}
		}
		//判断及格的人
		for(int i=0;i<student1s2.length;i++){
			double d=student1s2[i].getScore();
			if(d>=60){
				System.out.println("及格的人是："+student1s2[i].getName());
			}
		}
		//判断成绩个位是6的人
		for(int i=0;i<student1s2.length;i++){
			double d=student1s2[i].getScore();
			if(d%10==6){
				System.out.println("成绩个位是6的人："+student1s2[i].getName());
			}
		}
		//判断有几个女生  几个男的
		int count1=0,count2=0;
		for(int i=0;i<student1s2.length;i++){
			String s=student1s2[i].getSex();
			if(s.equals("男")){
				count1++;
			}else{
				count2++;	
			}
		}
		System.out.println("男生有："+count1+"个");
		System.out.println("女生有："+count2+"个");

		
	}
	
	

}
